<?php
namespace app\api\controller;
use app\api\logic\GoodsLogic;
use think\Request;
class GoodsController extends ApiBase
{
    protected $authExcept = [
        'goodslist','getGoodsDetail','getNewList'
    ];

    //商品数据
    public function goodslist(Request $request)
    {
        $get = $this->request->post();
        $user_id =$this->uid??0;
        $goods_list = GoodsLogic::getGoodsList($user_id,$get,$this->page,$this->limit);
        return success($goods_list);
    }

     /**
     * note 商品详情
     */
    public function getGoodsDetail(){
        $id = $this->request->get('id');
        $uid = $this->request->get('uid')??'';
        $goods = GoodsLogic::getGoodsDetail($id,$uid);
        if($goods){
            return success($goods);
        }
        return error('商品不存在',[],0,0);
    }

    /**
     * note 平台推荐
     */
    public function getRecommend(){
        
        $user_id =$this->uid??0;
        $goods_list = GoodsLogic::getNewList($user_id,$this->page,$this->limit);
        return success($goods_list);
    }

    /**
     * 首页轮播图
     */
    public function getBanner(){
        $banner = GoodsLogic::getBanner();
        return success($banner);
    }
}